#ifndef CONTENTDEALER_H
#define CONTENTDEALER_H

#include <QMutex>
#include <QMutexLocker>
#include <QString>
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
#include "./entities/message/superClass/message.h"


class ContentDealer
{
public:

    ContentDealer() = delete;
    ~ContentDealer() = delete;
    ContentDealer(const ContentDealer&) = delete;
    ContentDealer& operator=(const ContentDealer&) = delete;

    // 对ContentType为MESSAGE的类型进行打包
    static QByteArray JsonPack(const Message&);
    static QByteArray ImagePack(const QImage&);


    // 传入originContent，判断Content类型，返回unpackedContent
    static ContentType Unpack(const QByteArray& originContent, QByteArray& unpackedContent);
    // 传入jsonByteArray，判断Message类型，返回json对象
    static MessageType GetMessageType(const QByteArray& jsonByteArray, QJsonObject& jsonObj);

    static QImage ImageUnPack(const QByteArray&);


private:
    // Json对象转换为二进制序列
    static QByteArray JsonToByte(const QJsonObject&);
    // 二进制序列转换为Json对象
    static QJsonObject ByteToJson(const QByteArray&);

};

#endif // CONTENTDEALER_H
